var t = getApp(), a = void 0;

Page({
    data: {
        formData: {
            phone_number: "",
            code: ""
        },
        second: 60,
        notbind: !1
    },
    bindInput: function(t) {
        var a = t.currentTarget.dataset.name;
        this.data.formData[a] = t.detail.value, this.setData({
            formData: this.data.formData
        });
    },
    onLoad: function(t) {
        a = this;
    },
    getCode: function() {
        "" == this.data.formData.phone_number ? wx.showToast({
            title: "请输入手机号",
            icon: "none"
        }) : (wx.showLoading({
            title: "获取中",
            mask: !0
        }), t.com.post("wx/user/code", {
            phone_number: this.data.formData.phone_number
        }, function(t) {
            if (wx.hideLoading(), 0 === t.errno) {
                a.setData({
                    second: 60,
                    notbind: !0
                });
                var e = setInterval(function() {
                    a.data.second > 0 ? a.setData({
                        second: a.data.second - 1
                    }) : (a.setData({
                        second: 60,
                        notbind: !1
                    }), clearInterval(e));
                }, 1e3);
            }
        }));
    },
    submit: function(e) {
        var o = e.detail.rawData;
        11 != this.data.formData.phone_number.length ? wx.showToast({
            title: "请输入11位手机号",
            icon: "none"
        }) : "" == this.data.formData.code ? wx.showToast({
            title: "请输入验证码",
            icon: "none"
        }) : (wx.showLoading({
            title: "登录中",
            mask: !0
        }), t.com.post("wx/user/bindPhone", {
            phone_number: this.data.formData.phone_number,
            code: this.data.formData.code,
            user: o,
            superior_id: wx.getStorageSync("superior_id") || ""
        }, function(t) {
            wx.hideLoading(), 0 == t.errno && (wx.showToast({
                title: "登录成功",
                duration: 1e3,
                mask: !0
            }), wx.setStorage({
                key: "phone",
                data: a.data.formData.phone_number,
                success: function() {
                    setTimeout(function() {
                        wx.navigateBack({
                            delta: 1
                        });
                    }, 1e3);
                }
            }));
        }));
    },
    getWxphone: function(a) {
        wx.showLoading({
            title: "登录中",
            mask: !0
        }), a.detail.encryptedData && t.com.post("wx/user/getwxPhone", {
            encryptedData: a.detail.encryptedData,
            iv: a.detail.iv,
            superior_id: wx.getStorageSync("superior_id") || ""
        }, function(t) {
            wx.hideLoading(), 0 == t.errno && (wx.showToast({
                title: "登录成功",
                duration: 1e3,
                mask: !0
            }), wx.setStorage({
                key: "phone",
                data: t.data.phone,
                success: function() {
                    setTimeout(function() {
                        wx.navigateBack({
                            delta: 1
                        });
                    }, 1e3);
                }
            }));
        });
    }
});